﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Controls;
using System.Drawing;


namespace ShapeConnectors
{
    class Canh
    {
        private int u;

        public int U
        {
            get { return u; }
            set { u = value; }
        }
        private int v;

        public int V
        {
            get { return v; }
            set { v = value; }
        }
        private int trongso;

        public int Trongso
        {
            get { return trongso; }
            set { trongso = value; }
        }
        private LineGeometry line;

        public LineGeometry Line
        {
            get { return line; }
            set { line = value; }
        }
        private TextBlock textTS;

        public TextBlock TextTS
        {
            get { return textTS; }
            set { textTS = value; }
        }
        public void getTS(LineGeometry line, Canvas mycanvas)
        {
            Point p = new Point();
            p.X =Math.Abs((int) ((line.StartPoint.X - line.EndPoint.X) / 2));
            p.Y =Math.Abs( (int)((line.StartPoint.Y - line.EndPoint.Y) / 2));
            textTS = new TextBlock();

            textTS.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            textTS.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            textTS.TextAlignment = System.Windows.TextAlignment.Center;

            textTS.SetValue(Canvas.LeftProperty, p.X);
            textTS.SetValue(Canvas.TopProperty, p.Y);
            textTS.SetValue(Canvas.ZIndexProperty, 2);

            textTS.Text = trongso.ToString();
            mycanvas.Children.Add(textTS);
        }


        public Point GetLabel()
        {
            //= new ListCanh(); 
            int x = Math.Abs((int)((line.StartPoint.X + line.EndPoint.X) / 2));
            int y = Math.Abs((int)((line.StartPoint.Y + line.EndPoint.Y) / 2));
            
            
            return new Point(x, y);
        }

        public void Updatelb()
        {

            Point edgeLabelPoint = GetLabel();
            if (textTS == null)
            {
                textTS = new TextBlock();
                textTS.Text = trongso.ToString();
            }
            
            Canvas.SetLeft(textTS, edgeLabelPoint.X);
            Canvas.SetTop(textTS, edgeLabelPoint.Y);
            textTS.SetValue(Canvas.ZIndexProperty, 2);
            
        }
        
    }
}
